﻿using Microsoft.Practices.Unity.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Artech.Core
{
    public class DataAccessBuilder
    {
        private static DataAccessBuilder current;
        private DataAccessBuilder()
        {
            this.DataAccessAccessor = (databaseName, applicationName) => new DefaultDataAccess(databaseName, applicationName);
        }
        public static DataAccessBuilder Current
        {

            get { return current ?? (current = new DataAccessBuilder()); }
        }

        public DataAccessAccessor DataAccessAccessor { get; set; }
        public IDataAccess CreateDataAccess(string databaseName, string applicationName)
        {
            Guard.ArgumentNotNullOrEmpty(databaseName, "databaseName");
            Guard.ArgumentNotNullOrEmpty(applicationName, "applicationName");
            return this.DataAccessAccessor(databaseName, applicationName);
        }
    }
}
